class BankSimulation:
    def __init__(self):
        self.total_customers = 0
        self.total_services = 0
        self.total_service_time = 0
        self.window_customers = [0, 0, 0, 0]  # 每个窗口的客户数
        self.window_services = [set(), set(), set(), set()]  # 每个窗口每种业务的服务数

    def simulate(self, customer_id, window_id, type, service_time):
        print("{}号顾客在{}号窗口办理{}业务,花费{}分钟".format(customer_id, window_id + 1, type, service_time))

        operations = ['存款', '挂失', '取款', '还贷']
        service_type = 0
        for i in range(len(operations)):
            if type == operations[i]:
                service_type = i
        self.total_customers += 1
        self.total_services += 1
        self.total_service_time += service_time
        self.window_customers[window_id] += 1
        self.window_services[window_id].add(service_type)


    def calculate_average_stay_time(self):
        return self.total_service_time / self.total_customers if self.total_customers != 0 else 0

    def calculate_average_service_per_window(self):
        return [self.window_customers[i] if self.total_customers != 0 else 0 for i in range(4)]

    def service_type_per_window(self):
        return [(i + 1, len(self.window_services[i])) for i in range(4)]

    def print_result(self):
        print("平均每位客户逗留时间:", self.calculate_average_stay_time())
        print("每窗口服务客户数:", self.calculate_average_service_per_window())
        print("每窗口服务业务类型数:", self.service_type_per_window())


